feat(auth): add feature flags to disable temp users and user signups #63
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Summary
This PR adds two new configuration flags (
disable_temp_usersanddisable_user_signup) that allow administrators to control user access to the platform. When enabled, these flags prevent temporary user creation and/or new permanent account signups, returning appropriate 403 Forbidden errors.Motivation
Administrators need the ability to control user access in production environments. This is critical for:
Changes
Backend
disable_temp_usersanddisable_user_signupconfiguration flags inconfig.jstemp_users_disabledanduser_signup_disabledAPIError codes/signupendpoint for both temp and regular signups/save_accountendpoint to prevent temp-to-permanent conversion/whoamiendpoint to block existing temp user sessionsdisable_temp_usersincorrectly blocked all signups (not just temp users)Frontend
Configuration
Both flags can be configured in
volatile/config/config.json:{
"disable_temp_users": false, // Prevents automatic temp user creation
"disable_user_signup": false // Prevents new permanent account signups
}### Flag Combinations
falsefalsetruefalsefalsetruetruetrueTesting
Test Scenarios
Manual Testing Steps
Test temp users disabled:
{ "disable_temp_users": true, "disable_user_signup": false }
Test user signup disabled:
{ "disable_temp_users": false, "disable_user_signup": true }
Test both disabled:
{ "disable_temp_users": true, "disable_user_signup": true }
Error Responses
When features are disabled, the API returns 403 Forbidden with structured JSON:
{
"message": "Temporary user creation is disabled.",
"code": "temp_users_disabled"
}
{
"message": "New user signups are disabled.",
"code": "user_signup_disabled"
}## Backward Compatibility
✅ Fully backward compatible
false, maintaining existing behaviorFiles Changed
src/backend/src/config.js- Added configuration flagssrc/backend/src/api/APIError.js- Added error codessrc/backend/src/routers/signup.js- Added blocking logicsrc/backend/src/routers/save_account.js- Added blocking logicsrc/backend/src/routers/whoami.js- Added blocking logicsrc/gui/src/initgui.js- Updated error handlingsrc/gui/src/UI/UIWindowSignup.js- Updated error display